﻿//---------------------------------------------------------------------
//THIS CODE AND INFORMATION ARE PROVIDED AS IS WITHOUT WARRANTY OF ANY
//KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
//IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A
//PARTICULAR PURPOSE.
//---------------------------------------------------------------------

namespace Microsoft.Samples.Alert {

    using System;

    /// <summary>
    /// Event arguments used when an Alert option has been chosen.
    /// </summary>
    public class AlertChoiceEventArgs : EventArgs {

        private AlertResult _result = AlertResult.None;

        /// <summary>
        /// The chosen option in the Alert
        /// </summary>
        public AlertResult Result {
            get {
                return _result;
            }
            set {
                _result = value;
            }
        }

        /// <summary>
        /// Builds an AlertChoiceEventArgs object.
        /// </summary>
        /// <param name="buttons">The types of buttons</param>
        /// <param name="argument">The string argument the client returned</param>
        public AlertChoiceEventArgs(AlertButtons buttons, string argument) {
            switch (buttons) {
                case AlertButtons.AbortRetryIgnore:
                    switch (argument) {
                        case "true":
                            Result = AlertResult.Abort;
                            break;
                        case "false":
                            Result = AlertResult.Retry;
                            break;
                        default:
                            Result = AlertResult.Ignore;
                            break;
                    }
                    break;
                case AlertButtons.OK:
                    switch (argument) {
                        case "true":
                            Result = AlertResult.OK;
                            break;
                        default:
                            Result = AlertResult.None;
                            break;
                    }
                    break;
                case AlertButtons.OKCancel:
                    switch (argument) {
                        case "true":
                            Result = AlertResult.OK;
                            break;
                        case "false":
                            Result = AlertResult.Cancel;
                            break;
                        default:
                            Result = AlertResult.None;
                            break;
                    }
                    break;
                case AlertButtons.RetryCancel:
                    switch (argument) {
                        case "true":
                            Result = AlertResult.Retry;
                            break;
                        case "false":
                            Result = AlertResult.Cancel;
                            break;
                        default:
                            Result = AlertResult.None;
                            break;
                    }
                    break;
                case AlertButtons.YesNo:
                    switch (argument) {
                        case "true":
                            Result = AlertResult.Yes;
                            break;
                        case "false":
                            Result = AlertResult.No;
                            break;
                        default:
                            Result = AlertResult.None;
                            break;
                    }
                    break;
                case AlertButtons.YesNoCancel:
                    switch (argument) {
                        case "true":
                            Result = AlertResult.Yes;
                            break;
                        case "false":
                            Result = AlertResult.No;
                            break;
                        default:
                            Result = AlertResult.Cancel;
                            break;
                    }
                    break;
            }
        }
    }
}